//
//  ZZCGestureController.m
//  ZZC-Finance
//
//  Created by mac on 2017/5/25.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "ZZCGestureController.h"
#import "ZZCGestureView.h"
#import "ZZCGestureManageController.h"

@interface ZZCGestureController ()<ZZCGestureViewDelegate>
@property (strong, nonatomic) ZZCGestureView *gesView;
//头像
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
//管理手势密码
@property (weak, nonatomic) IBOutlet UIButton *manageBtn;
//view
@property (weak, nonatomic) IBOutlet UIView *bgView;
@end

@implementation ZZCGestureController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.iconView.image = [UIImage imageNamed:@"1.jpeg"];
    self.iconView.layer.cornerRadius = 4;
    self.iconView.clipsToBounds = YES;
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backPasswordResult:) name:@"backPasswordResult" object:nil];
  
}

- (void)viewDidLayoutSubviews {
    self.gesView = [[ZZCGestureView alloc]initWithFrame:self.bgView.bounds];
    self.gesView.delegate = self;
    [self.bgView addSubview:self.gesView];
     ZZCLog(@"%@",NSStringFromCGRect(self.bgView.frame));
}

- (void)backPasswordResult:(NSNotification *)notifi {
      [self.gesView setRigthResult:notifi.userInfo[@"result"]];
}

#pragma mark - ZZCGestureViewDelegate

//原密码为nil调用
- (void)GestureLockSetResult:(NSString *)result gestureView:(ZZCGestureView *)gestureView {
    ZZCLog(@"请先设置手势密码");
    [UIAlertController showInfoAlertLoginVC:self title:@"提示" message:@"请先设置手势密码" ok:nil];


}

//密码核对成功调用
- (void)GestureLockPasswordRight:(ZZCGestureView *)gestureView {
    ZZCLog(@"密码正确");
    [UIAlertController showInfoAlertLoginVC:self title:@"提示" message:@"手势密码输入正确" ok:nil];

}

//密码核对失败调用
- (void)GestureLockPasswordWrong:(ZZCGestureView *)gestureView {
    ZZCLog(@"密码错误");
  [UIAlertController showInfoAlertLoginVC:self title:@"提示" message:@"手势密码输入错误" ok:nil];

}




- (IBAction)backClick {
    [self.navigationController popViewControllerAnimated:YES];
}

//手势管理
- (IBAction)manageClick {
    ZZCGestureManageController *man = [ZZCGestureManageController new];
    [self.navigationController pushViewController:man animated:YES];
}


- (void)dealloc  {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
